package com.rotsel.mh3udb.app.Adapters;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.rotsel.mh3udb.app.R;
import com.rotsel.mh3udb.app.models.WeaponTypeModel;

public class PicTextListItemAdapter extends ArrayAdapter<WeaponTypeModel> {
	private final Context context;
	private final ArrayList<WeaponTypeModel> modelArrayList;
	
	public PicTextListItemAdapter(Context cont, ArrayList<WeaponTypeModel> list){
		super(cont, R.layout.weapon_type_item, list);
		
		this.context = cont;
		this.modelArrayList = list;
	}

    @Override
    public long getItemId(int position) {
        return modelArrayList.get(position).getId();
    }

    @Override
	public View getView(int position, View convertView, ViewGroup parent){
		LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		
		View rowView = inflater.inflate(R.layout.weapon_type_item, parent, false);
		
		ImageView imgView = (ImageView)rowView.findViewById(R.id.item_icon);
		TextView txtView = (TextView)rowView.findViewById(R.id.item_text);
		
		imgView.setImageResource(modelArrayList.get(position).getIcon());
		txtView.setText(modelArrayList.get(position).getName());
		
		return rowView;
	}
}
